package com.handinfo.android.ui.window;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.CopyOnWriteArrayList;

import android.graphics.Bitmap;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.core.object.Scene;
import com.handinfo.android.core.object.Scene.SceneHandler;
import com.handinfo.android.game.GameMessage;
import com.handinfo.android.game.IconManger;
import com.handinfo.android.game.Task;
import com.handinfo.android.game.item.ItemConstants;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWAbsHyperlink;
import com.handinfo.android.uicontrols.DWControlTools;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWControl;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWInputBox;
import com.handinfo.android.uicontrols.controls.DWListSubItem;
import com.handinfo.android.uicontrols.controls.DWListbox;
import com.handinfo.android.uicontrols.controls.DWMessageBox;
import com.handinfo.android.uicontrols.controls.DWPopMenu;
import com.handinfo.android.uicontrols.controls.DWTabControl;
import com.handinfo.android.uicontrols.controls.DWTabPage;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
import com.handinfo.android.utils.Tools;

public class UIRenWuWindow implements IUIWindows
{

	Bitmap m_cr_tab_1 = null;// 点击前图片
	Bitmap m_cr_tab_2 = null;// 点击后图片

	Bitmap m_cr_tc; // 退出叉键按钮的图片

	Bitmap m_cr_but; // /按钮的图片
	Bitmap m_cr_but_bianhou = null; ////按下按钮抬起前的改变
	Bitmap m_cr_xxbj = null;
	Bitmap m_cr_grid = null;
	Bitmap m_cr_fangqi = null;
	public DWFrame m_rw_Frame = null;
	DWTitle m_rw_tit; // /标题
	DWTabControl m_tabcontrol = null;

	DWBackground m_xbj_bg; // ////小背景的
	DWTitle m_liaotian_tit;
	DWBackground m_listbox_ima; // listbox
	DWBackground m_textbox_ima;
	public DWImageBox m_tc_ima; // /退出叉键按钮

	DWButton m_task_but; ///玩家身上的任务列表的接取放弃完成任务的按钮
	DWButton m_search_but; ///玩家身上的寻路按钮
	DWButton m_accept_but;
	DWButton m_everyday_but;
	public DWButton m_npc_but; ///npc任务详情界面的按钮

	DWPopMenu m_xunlu_pm;
	DWListbox[] m_listbox_data = null;

	DWTextbox m_task_information_textbox[];
	DWTextbox m_eveyday_text = null;

	int m_tp_index;
	DWTabPage m_tp[];

	// //标签页按钮的名字数组
	String[] m_stringname = new String[] { "剧情", "可接", "增次" };

	DWTextbox m_juqing_task_list_textbox[]; ///剧情每一个subitem里放的textbox 
	DWTextbox m_kejie_task_list_textbox_1[];
	DWTextbox m_kejie_task_list_textbox_2[];
	public Task m_task = null;
	CopyOnWriteArrayList<Task> m_jq_list;

	DWListSubItem m_lsi[];
	DWListSubItem m_lsi_1[];
	DWListSubItem m_lsi_2[];
	DWMessageBox m_mb = null;

	/******************* 网络接收 *********************/
	/**
	 * 读取玩家任务列表
	 * @param dis
	 * @throws IOException
	 */
	//////左侧的listbox的任务列表      剧情列表
	public void recvRoleTaskList(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		short state = dis.readShort();
		String msg = dis.readUTF();
		Tools.debugPrintln("msg:" + msg);
		if (state == 1) {
			byte dramaCount = dis.readByte();
			Tools.debugPrintln("剧情任务长度 : " + dramaCount);
			DWGameManager.getInstance().m_role.m_drama_list.clear();
			for (int i = 0; i < dramaCount; i++) {
				Task task = new Task();
				task.readTask(dis);
				DWGameManager.getInstance().m_role.m_drama_list.add(task);
				Tools.debugPrintln("创建一个剧情 : " + task.m_name + " : " + task.m_key + " : " + task.m_status);
			}
			DWGameManager.getInstance().m_role.m_drama_list = UIRenWuWindow
					.taskSort(DWGameManager.getInstance().m_role.m_drama_list);
			if (DWGameManager.getInstance().getGameState() == DWGameManager.GS_GAME) {
				open((byte) 0);
				UIWindows.getInstance().m_main.refreshTask();
			}
		}
		else {
			Tools.debugPrintln("读取玩家任务列表失败 : " + msg);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_A, msg);
		}
	}

	/**
	 * 可接任务列表接收
	 * @param dis
	 * @throws IOException
	 */
	public void recvRoleacceptablyTaskList(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		int acceptablyCount = dis.readInt();
		Tools.debugPrintln("可接任务长度 : " + acceptablyCount);
		DWGameManager.getInstance().m_role.m_acceptably_list.clear();

		for (int i = 0; i < acceptablyCount; i++) {
			Tools.debugPrintln("io : " + i);
			Task task = new Task();
			task.m_name = dis.readUTF();
			task.m_type = dis.readInt();
			task.m_key = dis.readUTF();
			task.m_status = dis.readByte();
			task.m_lv = dis.readInt();
			task.m_difficulty = dis.readByte();
			Tools.debugPrintln("创建一个可接 : " + task.m_name + " : " + task.m_type + task.m_key + " : " + task.m_status);
			DWGameManager.getInstance().m_role.m_acceptably_list.add(task);
		}
		DWGameManager.getInstance().m_role.m_acceptably_list = UIRenWuWindow
				.taskSort(DWGameManager.getInstance().m_role.m_acceptably_list);
		if (DWControlsManager.getInstance().contains(m_rw_Frame)) {
			if (m_rw_Frame != null) {
				if (m_listbox_data[1] != null) {
					m_listbox_data[1].removeAllSubItem();
				}
				CopyOnWriteArrayList<Task> m_list_1 = DWGameManager.getInstance().m_role.m_acceptably_list; ///定义一个得到任务的数据的类型的变量
				DWListSubItem m_lsi_3[] = new DWListSubItem[m_list_1.size()];
				m_kejie_task_list_textbox_2 = new DWTextbox[m_list_1.size()];
				for (int m_task_size_3 = 0; m_task_size_3 < m_list_1.size(); m_task_size_3++) {
					m_task = m_list_1.get(m_task_size_3);
					m_lsi_3[m_task_size_3] = new DWListSubItem();

					////任务列表的textbox
					m_kejie_task_list_textbox_2[m_task_size_3] = new DWTextbox(" " + m_task.m_name +
							" " + m_task.TASK_STATUS[m_task.m_status], m_listbox_data[1].getShowWidth());
					m_kejie_task_list_textbox_2[m_task_size_3].setNearAnchor(m_lsi_3[m_task_size_3], Tools.LEFT_TOP,
							Tools.LEFT_TOP,
							0, 0);
					m_kejie_task_list_textbox_2[m_task_size_3].addListener(m_textbox_lis);
					m_lsi_3[m_task_size_3].addControls(m_kejie_task_list_textbox_2[m_task_size_3]);
					m_listbox_data[1].addSubItem(m_lsi_3[m_task_size_3]);
				}

				Task m_task_list_0 = null;
				if (DWGameManager.getInstance().m_role.m_acceptably_list.size() != 0
						&& DWGameManager.getInstance().m_role.m_acceptably_list != null) {
					m_task_operate_id = 0;
					m_task_list_0 = DWGameManager.getInstance().m_role.m_acceptably_list.get(m_task_operate_id);
				}

				if (m_task_list_0 != null) {
					m_task_operate_id = 0;
					DWGameManager.getInstance().getSendMessage().sendNPCTaskView(m_task_list_0.m_key);
				}
			}
		}
		UIWindows.getInstance().m_main.refreshTask();
	}

	private int m_task_operate_id = 0;

	/**
	 * 读取玩家任务详细信息
	 * @param dis
	 * @throws IOException
	 */

	///////接收点击左侧的listbox的中的任务后，右侧的textbbox里的任务详情描述
	public void recvTaskViewRole(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 1) {
			m_task = new Task();

			m_task.m_key = dis.readUTF();//任务key
			Tools.debugPrintln("任务key: " + m_task.m_key);
			m_task.m_name = dis.readUTF();//任务名字
			Tools.debugPrintln("任务名称: " + m_task.m_name);
			m_task.m_type = dis.readInt();
			Tools.debugPrintln("任务类型: " + m_task.m_type);
			m_task.m_lv = dis.readInt();//接受等级
			Tools.debugPrintln("任务等级: " + m_task.m_lv);
			m_task.m_difficulty = dis.readByte();//难度
			Tools.debugPrintln("任务难度等级: " + m_task.m_difficulty);
			m_task.m_status = dis.readByte();//状态 0未接,其他为已接,已完成
			Tools.debugPrintln("任务状态: " + m_task.m_status);
			m_task.m_depict = dis.readUTF();//描述
			Tools.debugPrintln("任务描述: " + m_task.m_depict);
			m_task.m_progress = dis.readUTF();//进度提示
			Tools.debugPrintln("任务进度 : " + m_task.m_progress);
			m_task.m_exp = dis.readInt();//经验奖励
			Tools.debugPrintln("任务奖励经验数值: " + m_task.m_exp);
			m_task.m_money = dis.readInt();//金币奖励
			Tools.debugPrintln("任务奖励金钱数值: " + m_task.m_money);

			byte itemsize = dis.readByte();//道具奖励长度
			m_task.m_propID = new String[itemsize];// 奖励道具key
			m_task.m_propCount = new int[itemsize];// 奖励道具数量
			m_task.m_propName = new String[itemsize];///道具的名字
			m_task.m_propIcon = new short[itemsize];///道具的名字
			for (byte i = 0; i < itemsize; i++) {
				m_task.m_propID[i] = dis.readUTF();
				m_task.m_propCount[i] = dis.readInt();
				m_task.m_propName[i] = dis.readUTF();
				m_task.m_propIcon[i] = dis.readShort();
			}

			byte moneysize = dis.readByte();//额外货币长度
			m_task.m_renownID = new String[moneysize];// 奖励声望ID
			m_task.m_renownCount = new int[moneysize];// 奖励声望数量
			for (byte i = 0; i < moneysize; i++) {
				m_task.m_renownID[i] = dis.readUTF();
				m_task.m_renownCount[i] = dis.readInt();
			}

			//////右侧的textbox里的内容
			String m_task_m_depict_2 = new String(m_task.m_depict + DWControlTools.CHANGE_ROW + "任务目标：" +
					DWControlTools.CHANGE_ROW + m_task.m_progress + DWControlTools.CHANGE_ROW +
					DWControlTools.CHANGE_ROW + "<mark c=" + getcolor(ItemConstants.稀有度_橙) + ">" + "任务奖励：" + "</mark>"
					+ DWControlTools.CHANGE_ROW + "经验值："
					+ m_task.m_exp + DWControlTools.CHANGE_ROW + "金钱：  " + m_task.m_money + "金");

			m_task_information_textbox[0].setText(m_task_m_depict_2);
			Tools.debugPrintln("任务的详情：" + m_task_m_depict_2);
			m_task_but.setShow(true);
			m_task_but.setTouch(true);
			m_search_but.setShow(true);
			m_search_but.setTouch(true);
			if (!m_kejie_flag) {
				m_kejie_flag = true;
				DWGameManager.getInstance().getSendMessage().sendTaskacceptablyTaskList();
			}
		}
		else {
			Tools.debugPrintln("读取任务详细信息失败 : " + msg);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_A, msg);
		}
		UIWindows.getInstance().m_main.refreshTask();
	}

	/**
	 * 读取放弃任务
	 * 
	 * @param dis
	 * @throws IOException
	 */
	///////等同于删除任务
	public void recvTaskAbort(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 1) {
			Tools.debugPrintln("放弃任务 : " + state + " : " + msg);
			if (!msg.equals("")) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C, msg);
			}
			DWGameManager.getInstance().m_role.stay(DWGameManager.getInstance().m_role.m_direct);
			DWGameManager.getInstance().m_role.clearPathfinding();

			if (DWControlsManager.getInstance().contains(m_jiequ_frame)) {
				for (int i = 0; i < DWGameManager.getInstance().m_role.m_drama_list.size(); i++) {
					if (m_task.m_key.equals(DWGameManager.getInstance().m_role.m_drama_list.get(i).m_key)) {
						DWGameManager.getInstance().m_role.m_drama_list.remove(i);
					}
				}
				DWControlsManager.getInstance().removeControl(m_jiequ_frame);
				DWGameManager.getInstance().getSendMessage().sendTaskacceptablyTaskList();
				UIWindows.getInstance().m_main.refreshTask();
				return;
			}
			m_task_but.setShow(false);
			m_task_but.setTouch(false);
			m_search_but.setShow(false);
			m_search_but.setTouch(false);
			m_task_information_textbox[0].setText("");
			DWGameManager.getInstance().m_role.m_drama_list.remove(m_touch_index);
			m_jq_list = DWGameManager.getInstance().m_role.m_drama_list;
			Tools.debugPrintln("m_jq_list.size():" + m_jq_list.size());

			if (m_listbox_data[0] != null) {
				m_listbox_data[0].removeAllSubItem();
			}
			if (m_jq_list.size() > 0) {
				DWTextbox m_juqing_task_list_textbox[] = new DWTextbox[m_jq_list.size()];
				for (int m_del_list = 0; m_del_list < m_jq_list.size(); m_del_list++) {
					DWListSubItem m_lis = new DWListSubItem();
					m_juqing_task_list_textbox[m_del_list] = new DWTextbox(" " + m_jq_list.get(m_del_list).m_name +
							" " + m_jq_list.get(m_del_list).TASK_STATUS[m_task.m_status], m_listbox_data[0]
							.getShowWidth());
					m_juqing_task_list_textbox[m_del_list].setNearAnchor(m_lis, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_juqing_task_list_textbox[m_del_list].addListener(m_textbox_lis);

					m_lis.addControls(m_juqing_task_list_textbox[m_del_list]);
					m_listbox_data[0].addSubItem(m_lis);
				}
				m_task_operate_id = 0;
				m_listbox_data[0].setTouchIndex(0);
				DWGameManager.getInstance().getSendMessage().sendRoleTaskView(
						DWGameManager.getInstance().m_role.m_drama_list.get(m_task_operate_id).m_key);
			}
			else if (m_jq_list == null || m_jq_list.size() == 0) {
				m_task_information_textbox[0].setText("现在已无剧情任务了,点击可接可查看未接任务，并能接取 ^-^");
				DWGameManager.getInstance().getSendMessage().sendTaskacceptablyTaskList();
				m_kejie_flag = true;
			}
			UIWindows.getInstance().m_main.refreshTask();
		}
		else {
			Tools.debugPrintln("放弃失败  : " + msg);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_A, msg);
		}
	}

	public boolean m_kejie_flag = true;
	////////////////////////点击主界面任务按钮的界面代码///////////////////////////////////////////
	Bitmap m_cr_tit = null;

	public void RenWu()
	{
		if (DWControlsManager.getInstance().contains(m_rw_Frame)) {
			if (m_rw_Frame != null) {
				DWControlsManager.getInstance().removeControl(m_rw_Frame);
			}
		}
		// ////画布
		m_rw_Frame = new DWFrame(DWFrame.FRAME_TYPE_FULL, true);
		m_rw_Frame.setClickClose(false);
		// ////标题
		m_rw_tit = new DWTitle("", m_rw_Frame);
		DWImageBox m_tit_ima = new DWImageBox(m_cr_tit);
		m_tit_ima.setNearAnchor(m_rw_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);

		// //小背景图片
		// ///小背景和画布大背景的间隙是不变的 左右 间隙是15 下面间隙是20
		m_xbj_bg = new DWBackground(
				m_rw_Frame.getShowWidth() - 40, m_rw_Frame.getShowHeight()
						- (m_rw_tit.getShowHeight() - 20) - m_cr_tab_2.getHeight() - 20);
		m_xbj_bg.setNearAnchor(m_rw_Frame, Tools.LEFT_TOP, Tools.LEFT_TOP,
				(m_rw_Frame.getShowWidth() - m_xbj_bg.getShowWidth()) / 2,
				(m_rw_tit.getShowHeight() - 20) + m_cr_tab_2.getHeight());

		// //////////listbox图片
		m_listbox_ima = new DWBackground(m_cr_xxbj, 2 * (m_xbj_bg.getShowWidth() - 60) / 7,
				m_xbj_bg.getShowHeight() - 20);
		m_listbox_ima.setFill(false);

		// //////////////textbox图片
		m_textbox_ima = new DWBackground(m_cr_xxbj, 5 * (m_xbj_bg.getShowWidth() - 60) / 7,
				m_xbj_bg.getShowHeight() - 20);

		m_listbox_ima.setNearAnchor(m_xbj_bg, Tools.LEFT_TOP, Tools.LEFT_TOP,
				(m_xbj_bg.getShowWidth() - (m_listbox_ima.getShowWidth() + 20 + m_textbox_ima.getShowWidth())) / 2,
				(m_xbj_bg.getShowHeight() - m_listbox_ima.getShowHeight()) / 2);

		m_textbox_ima.setNearAnchor(m_listbox_ima, Tools.LEFT_TOP,
				Tools.RIGHT_TOP, 20, 0);

		// ////标签页
		// /////标签页任务列表的数组 Listbox
		m_listbox_data = new DWListbox[m_stringname.length];
		m_task_information_textbox = new DWTextbox[m_stringname.length];
		// ////标签容器
		//m_tabcontrol的宽：listbox_ima的宽-20，再+20listbox与textbox的宽，再+textbox_ima的宽-20，高：listbox_ima的高+标签页点击后的图片的高-15
		m_tabcontrol = new DWTabControl(m_cr_tab_1, m_cr_tab_2,
				m_listbox_ima.getShowWidth() - 20 + 20 + m_textbox_ima.getShowWidth(),
				m_listbox_ima.getShowHeight() + m_cr_tab_2.getHeight());
		m_tabcontrol
				.setNearAnchor(
						m_xbj_bg,
						Tools.LEFT_TOP,
						Tools.LEFT_TOP,
						((m_xbj_bg.getShowWidth() - (m_listbox_ima.getShowWidth() + 20 + m_textbox_ima.getShowWidth())) / 2) + 20,
						-m_cr_tab_2.getHeight());
		m_tabcontrol.addListener(m_tabcontrol_lis);
		m_tp = new DWTabPage[m_stringname.length];

		///定义一个得到任务的数据的类型的变量
		for (m_tp_index = 0; m_tp_index < m_stringname.length; m_tp_index++) {
			m_tp[m_tp_index] = new DWTabPage();
			m_tp[m_tp_index].setName(m_stringname[m_tp_index]);

			//******左侧的任务列表
			m_listbox_data[m_tp_index] = new DWListbox(m_listbox_ima.getShowWidth() - 40,
					m_listbox_ima.getShowHeight() - 30);
			m_listbox_data[m_tp_index].setNearAnchor(m_tp[m_tp_index], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, (m_xbj_bg
					.getShowHeight() - m_listbox_ima.getShowHeight()) / 2 + 15);
			m_listbox_data[m_tp_index].setLineSpacing(10);
			if (m_listbox_data[m_tp_index] != null) {
				m_listbox_data[m_tp_index].removeAllSubItem();
			}
			if (m_tp_index == 0) {
				CopyOnWriteArrayList<Task> m_list_1 = DWGameManager.getInstance().m_role.m_drama_list;
				if (m_list_1.size() != 0) {
					m_listbox_data[m_tp_index].setTouchIndex(0);
					m_listbox_data[m_tp_index].setScrollbar(0);
					m_lsi_1 = new DWListSubItem[m_list_1.size()];
					m_juqing_task_list_textbox = new DWTextbox[m_list_1.size()];
					for (int m_task_size_1 = 0; m_task_size_1 < m_list_1.size(); m_task_size_1++) {
						Task m_task = m_list_1.get(m_task_size_1);
						m_lsi_1[m_task_size_1] = new DWListSubItem();
						////任务列表的textbox
						m_juqing_task_list_textbox[m_task_size_1] = new DWTextbox(" " + m_task.m_name +
								" " + m_task.TASK_STATUS[m_task.m_status],
								m_listbox_data[m_tp_index].getShowWidth());
						m_juqing_task_list_textbox[m_task_size_1].setNearAnchor(m_lsi_1[m_task_size_1], Tools.LEFT_TOP,
								Tools.LEFT_TOP,
								0, 0);
						m_juqing_task_list_textbox[m_task_size_1].addListener(m_textbox_lis);
						m_lsi_1[m_task_size_1].addControls(m_juqing_task_list_textbox[m_task_size_1]);
						m_listbox_data[m_tp_index].addSubItem(m_lsi_1[m_task_size_1]);
					}
				}
			}
			else if (m_tp_index == 1) {
				CopyOnWriteArrayList<Task> m_list_2 = DWGameManager.getInstance().m_role.m_acceptably_list;
				if (m_list_2.size() != 0) {
					m_listbox_data[m_tp_index].setTouchIndex(0);
					m_listbox_data[m_tp_index].setScrollbar(0);
					m_lsi_2 = new DWListSubItem[m_list_2.size()];
					m_kejie_task_list_textbox_1 = new DWTextbox[m_list_2.size()];
					for (int m_task_size_2 = 0; m_task_size_2 < m_list_2.size(); m_task_size_2++) {
						Task m_task = m_list_2.get(m_task_size_2);

						m_lsi_2[m_task_size_2] = new DWListSubItem();
						////任务列表的textbox
						m_kejie_task_list_textbox_1[m_task_size_2] = new DWTextbox(" " + m_task.m_name +
								" " + m_task.TASK_STATUS[m_task.m_status],
								m_listbox_data[m_tp_index].getShowWidth());
						m_kejie_task_list_textbox_1[m_task_size_2].setNearAnchor(m_lsi_2[m_task_size_2],
								Tools.LEFT_TOP,
								Tools.LEFT_TOP,
								0, 0);
						m_kejie_task_list_textbox_1[m_task_size_2].addListener(m_textbox_lis);

						m_lsi_2[m_task_size_2].addControls(m_kejie_task_list_textbox_1[m_task_size_2]);
						m_listbox_data[m_tp_index].addSubItem(m_lsi_2[m_task_size_2]);
					}
				}
			}
			m_task_information_textbox[m_tp_index] = new DWTextbox(" ",
					5 * (m_tabcontrol.getShowWidth() - 40 - 20) / 7,
					m_textbox_ima.getShowHeight() - m_cr_but.getHeight() - 20 - 20);
			m_task_information_textbox[m_tp_index].setNearAnchor(m_tp[m_tp_index], Tools.LEFT_TOP, Tools.LEFT_TOP,
					m_listbox_ima.getShowWidth() + 20, (m_xbj_bg
							.getShowHeight() - m_listbox_ima.getShowHeight()) / 2 + 15);
			m_task_information_textbox[m_tp_index].addListener(m_information_text_lis);
			if (m_task_information_textbox[m_tp_index] != null) {
				m_task_information_textbox[m_tp_index].setText("");
			}
			if (m_tp_index == 0) {
				if (DWGameManager.getInstance().m_role.m_drama_list.size() == 0) {
					m_task_information_textbox[0].setText("现在已无剧情任务了,点击可接可查看未接任务，并能接取 ^-^");
				}
			}
			if (m_tp_index == 0) {
				m_search_but = new DWButton("寻路", m_cr_but);
				m_search_but.setShow(false);
				m_search_but.setTouch(false);
				m_search_but.setDownImage(m_cr_but_bianhou);
				m_search_but.addListener(m_juqing_search_but_lis);
				m_search_but.setNearAnchor(m_tp[m_tp_index], Tools.RIGHT_BOTTOM,
						Tools.RIGHT_BOTTOM, -10, -2);
				m_tp[m_tp_index].addControls(m_search_but);

				m_task_but = new DWButton("删除任务", m_cr_but);
				m_task_but.setDownImage(m_cr_but_bianhou);
				m_task_but.setShow(false);
				m_task_but.setTouch(false);
				m_task_but.addListener(m_fangqi_but_lis);
				m_task_but.setNearAnchor(m_search_but, Tools.RIGHT_BOTTOM,
						Tools.LEFT_BOTTOM, -10, 0);
				m_tp[m_tp_index].addControls(m_task_but);
			}
			else if (m_tp_index == 1) {
				m_accept_but = new DWButton("接取任务", m_cr_but);
				m_accept_but.setDownImage(m_cr_but_bianhou);
				m_accept_but.setShow(false);
				m_accept_but.setTouch(false);
				m_accept_but.addListener(m_kejie_search_but_lis);
				m_accept_but.setNearAnchor(m_tp[m_tp_index], Tools.RIGHT_BOTTOM,
						Tools.RIGHT_BOTTOM, -10, -2);
				m_tp[m_tp_index].addControls(m_accept_but);
			}
			else if (m_tp_index == 2) {
				int m_count = (m_all_count - m_alreay_count) + m_alreay_buy_count;
//				m_eveyday_text = new DWTextbox("今日每日任务已经完成数量：" + "<mark c=FFBB11>" + m_alreay_count  + "</mark>"+ "次"
//						+ DWControlTools.CHANGE_ROW
//						+ "今日还可完成每日任务数量：" + "<mark c=FFBB11>" + m_count 
//						+ "</mark>"+ "次");
				m_eveyday_text = new DWTextbox("今日每日任务已经完成数量：    次"
						+ DWControlTools.CHANGE_ROW
						+ "今日还可完成每日任务数量：   次", (int) DWFont.getDefaultFont().stringWidth("国") * 16);
				m_eveyday_text.setNearAnchor(m_task_information_textbox[2], Tools.HCENTER_VCENTER,
						Tools.HCENTER_VCENTER, 0, 0);

				m_everyday_but = new DWButton("每日增次", m_cr_but);
				m_everyday_but.setDownImage(m_cr_but_bianhou);
				m_everyday_but.addListener(m_everyday_but_lis);
				m_everyday_but.setNearAnchor(m_tp[m_tp_index], Tools.RIGHT_BOTTOM,
						Tools.RIGHT_BOTTOM, -10, -2);
				m_tp[m_tp_index].addControls(m_eveyday_text);
				m_tp[m_tp_index].addControls(m_everyday_but);
			}

			m_tp[m_tp_index].addControls(m_listbox_data[m_tp_index]);
			m_tp[m_tp_index].addControls(m_task_information_textbox[m_tp_index]);
			m_tabcontrol.addTabPage(m_tp[m_tp_index]);
		}

		// /////////退出按钮
		m_tc_ima = new DWImageBox(m_cr_tc);
		m_tc_ima.addListener(m_tc_lis);
		m_tc_ima.setTouchZoomIn(40, 40);
		m_tc_ima.setNearAnchor(m_rw_tit, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);

		m_rw_Frame.addControl(m_xbj_bg);
		m_rw_Frame.addControl(m_rw_tit);
		m_rw_Frame.addControl(m_tit_ima);
		m_rw_Frame.addControl(m_tc_ima);
		m_rw_Frame.addControl(m_listbox_ima);
		m_rw_Frame.addControl(m_textbox_ima);
		m_rw_Frame.addControl(m_tabcontrol);
		DWControlsManager.getInstance().addControl(m_rw_Frame);

		Task m_task_list_0 = null;
		if (DWGameManager.getInstance().m_role.m_drama_list.size() != 0
				&& DWGameManager.getInstance().m_role.m_drama_list != null) {
			m_task_operate_id = 0;
			m_task_list_0 = DWGameManager.getInstance().m_role.m_drama_list.get(m_task_operate_id);
		}
		if (m_task_list_0 != null) {
			m_task_operate_id = 0;
			DWGameManager.getInstance().getSendMessage().sendRoleTaskView(m_task_list_0.m_key);
		}
	}

	private DWListener m_tabcontrol_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_tabcontrol.getPageIndex() == 0) {
				m_listbox_data[0].setTouchIndex(0);
				m_listbox_data[0].setScrollbar(0);
				Task m_task_list_0 = null;
				if (DWGameManager.getInstance().m_role.m_drama_list.size() != 0
						&& DWGameManager.getInstance().m_role.m_drama_list != null) {
					m_task_operate_id = 0;
					m_task_list_0 = DWGameManager.getInstance().m_role.m_drama_list.get(m_task_operate_id);
					DWGameManager.getInstance().getSendMessage().sendRoleTaskView(m_task_list_0.m_key);
				}

				if (m_task_list_0 != null) {
					m_task_operate_id = 0;
				}
				if (DWGameManager.getInstance().m_role.m_drama_list.size() == 0) {
					m_task_information_textbox[0].setText("现在已无剧情任务了,点击可接能查看未接任务，并能接取  ^-^");
				}
			}
			else if (m_tabcontrol.getPageIndex() == 1) {
				m_listbox_data[1].setTouchIndex(0);
				m_listbox_data[1].setScrollbar(0);
				Task m_task_list_0 = null;
				if (DWGameManager.getInstance().m_role.m_acceptably_list.size() != 0
						&& DWGameManager.getInstance().m_role.m_acceptably_list != null) {
					m_task_operate_id = 0;
					m_task_list_0 = DWGameManager.getInstance().m_role.m_acceptably_list.get(m_task_operate_id);
				}
				if (m_task_list_0 != null) {
					m_task_operate_id = 0;
					DWGameManager.getInstance().getSendMessage().sendNPCTaskView(m_task_list_0.m_key);
				}
				if (DWGameManager.getInstance().m_role.m_acceptably_list.size() == 0)
				{
					m_task_information_textbox[1]
							.setText("现在已无可接任务，您还有未完成的任务哦，先加油完成吧   ^-^。");
				}
			}
			else if (m_tabcontrol.getPageIndex() == 2)
			{
				DWGameManager.getInstance().getSendMessage().sendEveryday();////发送每日任务的进度的指令。
			}
		}
	};

	byte m_alreay_count = 0;
	byte m_all_count = 0;//购买之前
	byte m_alreay_buy_count = 0;//已经购买的次数
	byte m_vip_can_buy_time = 0;
	int m_yuanbao_huilv = 0;

	public void recvEverydayNormalCount(DataInputStream dis) throws IOException
	{
		m_alreay_count = dis.readByte();
		m_all_count = dis.readByte();
		m_alreay_buy_count = dis.readByte();
		m_vip_can_buy_time = dis.readByte();
		m_yuanbao_huilv = dis.readInt();
		Tools.debugPrintln("今日已经完成的数量：" + m_alreay_count);
		Tools.debugPrintln("今日每日任务的总数量：" + m_all_count);
		Tools.debugPrintln("今日已经购买的数量：" + m_alreay_buy_count);
		Tools.debugPrintln("今日VIP可以购买的数量：" + m_vip_can_buy_time);
		Tools.debugPrintln("汇率：" + m_yuanbao_huilv);

		m_longest = m_vip_can_buy_time - m_alreay_buy_count;
		m_gold = m_longest * m_yuanbao_huilv;
		if (DWControlsManager.getInstance().contains(m_rw_Frame)) {
			int m_count = (m_all_count - m_alreay_count) + m_alreay_buy_count;
			m_eveyday_text.setText("今日每日任务已经完成数量：" + "<mark c=FFBB11>" + m_alreay_count + "</mark>" + "次"
					+ DWControlTools.CHANGE_ROW
					+ "今日还可完成每日任务数量：" + "<mark c=FFBB11>" + m_count + "</mark>" + "次");
			if (DWControlsManager.getInstance().contains(m_everyday_frame)) {
				if (m_input != null) {
					m_input.setText(Integer.toString(m_longest));
				}
				if (m_must_text != null) {
					m_must_text.setText("需要" + "<mark c=ffc001>" + m_gold + "</mark>");
					m_jinbi_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
				}
				if (m_count_text != null) {
					if (DWGameManager.getInstance().m_role.m_vip_lv == 0) {
						m_count_text.setText("<mark c=ffc001>" + "非VIP玩家，今日还可购买" + "</mark>" +
								"<mark c=55FF00>" + m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
					}
					else if (DWGameManager.getInstance().m_role.m_vip_lv > 0) {
						m_count_text.setText("<mark c=ffc001>" + "VIP" + DWGameManager.getInstance().m_role.m_vip_lv
								+ "玩家，今日还可购买" + "</mark>"
								+ "<mark c=55FF00>" + m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
					}
				}
			}
		}
		else
		{
			if (m_alreay_count == m_all_count)
			{
				if (m_mb != null && DWControlsManager.getInstance().contains(m_mb))
				{
					DWControlsManager.getInstance().removeControl(m_mb);
				}
				m_mb = new DWMessageBox("温馨提示", "您今日的每日任务已经全部完成，您是否增次每日任务，获得更多经验和金币。", "确定", "返回");
				m_mb.setTop(true);
				DWControlsManager.getInstance().addControl(m_mb);
				m_mb.addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK)
						{
							if ((m_vip_can_buy_time - m_alreay_buy_count) != 0)
							{
								if (m_rw_Frame != null && !DWControlsManager.getInstance().contains(m_rw_Frame))
								{
									RenWu();
									m_tabcontrol.setSelectPage(2);
									DWGameManager.getInstance().getSendMessage().sendEveryday();
								}
								else if (DWControlsManager.getInstance().contains(m_rw_Frame))
								{
									m_tabcontrol.setSelectPage(2);
									DWGameManager.getInstance().getSendMessage().sendEveryday();
								}
							}
							else
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"抱歉,您今日的增次数量用尽。");
							}
						}
						else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK)
						{
						}
						DWControlsManager.getInstance().removeControl(m_mb);
					}
				});
			}
		}
	}

	public void KeJie()
	{
		m_tabcontrol.setSelectPage(1);
		m_listbox_data[1].setTouchIndex(0);
		m_listbox_data[1].setScrollbar(0);
		Task m_task_list_0 = null;
		if (DWGameManager.getInstance().m_role.m_acceptably_list.size() != 0
				&& DWGameManager.getInstance().m_role.m_acceptably_list != null) {
			m_task_operate_id = 0;
			m_task_list_0 = DWGameManager.getInstance().m_role.m_acceptably_list.get(m_task_operate_id);
		}
		if (m_task_list_0 != null) {
			m_task_operate_id = 0;
			DWGameManager.getInstance().getSendMessage().sendNPCTaskView(m_task_list_0.m_key);
		}
		if (DWGameManager.getInstance().m_role.m_acceptably_list.size() == 0) {
			m_task_information_textbox[1]
					.setText("现在已无可接任务，您还有未完成的任务哦，先加油完成吧   ^-^。");
		}
	}

	private DWListener m_information_text_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_task_information_textbox[m_tabcontrol.getPageIndex()] != null
					&& m_task_information_textbox[m_tabcontrol.getPageIndex()].getHyperlinkKey() != null) {
				if (m_task_information_textbox[m_tabcontrol.getPageIndex()].getHyperlinkType() == DWAbsHyperlink.URL_NPC) {
					DWControlsManager.getInstance().removeControl(m_rw_Frame);
					DWGameManager.getInstance().getSendMessage().sendScenePathfinding(
							m_task_information_textbox[m_tabcontrol.getPageIndex()].getHyperlinkKey());
				}
			}
		}
	};

	/**
	 * 任务界面
	 */

	// //叉键退出监听
	private DWListener m_tc_lis = new DWListener() {

		public void OnDoubleClick()
		{

		}

		public void OnClick()
		{
			DWControlsManager.getInstance().removeControl(m_rw_Frame);
		}
	};
	/**
	 * 关于剧情
	 */
	///剧情任务的寻路监听
	private DWListener m_juqing_search_but_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWControlsManager.getInstance().removeControl(m_rw_Frame);
			DWGameManager.getInstance().getSendMessage().sendScenePathfinding(DWGameManager.getInstance().
					m_role.m_drama_list.get(m_listbox_data[0].getTouchIndex()).m_key);
			UIHook.closeHook();
			DWGameManager.getInstance().m_role.breakAutoAttack();
		}
	};
	// ///////////////剧情任务的标签下的放弃任务的按钮的监听
	int m_touch_index = 0;
	private DWListener m_fangqi_but_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			m_touch_index = m_listbox_data[0].getTouchIndex();
			final DWMessageBox m_messagebox = new DWMessageBox("温馨提示", "确认放弃当前任务？");
			DWControlsManager.getInstance().addControl(m_messagebox);
			m_messagebox.addListener(new DWListener() {
				public void OnDoubleClick()
				{
				}

				public void OnClick()
				{
					if (m_messagebox.getResult() == DWMessageBox.SOFTKEY_OK) {
						m_kejie_flag = false;
						DWGameManager.getInstance().getSendMessage().sendTaskAbort(DWGameManager.getInstance().
								m_role.m_drama_list.get(m_listbox_data[0].getTouchIndex()).m_key);
					}
					else if (m_messagebox.getResult() == DWMessageBox.SOFTKEY_BACK) {
					}
					DWControlsManager.getInstance().removeControl(m_messagebox);
				}
			});
		}
	};
	/**
	 * 关于可接任务
	 */
	//可接任务的寻路按钮监听
	public int index = 0;
	private DWListener m_kejie_search_but_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			index = m_listbox_data[1].getTouchIndex();
			Tools.debugPrintln("index:" + index);
			DWControlsManager.getInstance().removeControl(m_rw_Frame);
			DWGameManager.getInstance().getSendMessage().sendScenePathfinding(DWGameManager.getInstance().
					m_role.m_acceptably_list.get(index).m_key);
			UIHook.closeHook();
			DWGameManager.getInstance().m_role.breakAutoAttack();
		}
	};
	/**
	 * 关于每日任务
	 */
	//每日任务增次的按钮监听
	private DWListener m_everyday_but_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_vip_can_buy_time == 0)
			{
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉,您今日的增次数量用尽。");
			}
			else if (m_vip_can_buy_time > 0)
			{
				EverydayCount();
			}
		}
	};

	public DWFrame m_everyday_frame = null;
	public DWImageBox m_tuichu_ima = null;
	public DWBackground m_xbj = null;
	public DWImageBox m_left_ima = null;
	public DWImageBox m_right_ima = null;
	public DWButton m_but = null;
	public DWInputBox m_input = null;
	public DWTextbox m_must_text = null;
	public DWTextbox m_count_text = null;
	public DWImageBox m_jinbi_ima = null;
	public Bitmap m_cr_yunbao = null;
	public Bitmap m_cr_left = null;
	public Bitmap m_cr_right = null;
	public Bitmap m_cr_everyday_tit = null;
	int m_longest = 0;
	int m_gold = 0;
	byte m_count = 0;

	public void recvAddEverydayBuy(DataInputStream dis) throws IOException
	{
		byte m_status = dis.readByte();
		if (m_status == 0) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉，购买每日任务次数失败。");
		}
		else if (m_status == 1) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "恭喜，成功购买" + m_count + "次每日任务。");
			DWGameManager.getInstance().getSendMessage().sendEveryday();
		}
		Tools.debugPrintln("状态" + m_status);
	}

	public void EverydayCount()
	{
		if (DWControlsManager.getInstance().contains(m_everyday_frame)) {
			if (m_everyday_frame != null) {
				DWControlsManager.getInstance().removeControl(m_everyday_frame);
			}
		}
		if (DWGameManager.AdpaterType == DWGameManager.AD_HIGH)
		{
			m_everyday_frame = new DWFrame(500, 400);
		}
		else
		{
			m_everyday_frame = new DWFrame(400, 300);
		}
		m_everyday_frame.setClickClose(false);
		m_everyday_frame.setCentre();
		DWControlsManager.getInstance().addControl(m_everyday_frame);

		DWTitle m_tit = new DWTitle("", m_everyday_frame);
		DWImageBox m_tit_ima = new DWImageBox(m_cr_everyday_tit);
		m_tit_ima.setNearAnchor(m_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);

		m_tuichu_ima = new DWImageBox(m_cr_tc);
		m_tuichu_ima.setNearAnchor(m_tit, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
		m_tuichu_ima.setTouchZoomIn(20, 20);
		m_tuichu_ima.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_everyday_frame);
			}
		});

		m_xbj = new DWBackground(m_everyday_frame.getShowWidth() - 20, m_everyday_frame.getShowHeight()
				- (m_tit.getShowHeight() - 20) - 20);
		m_xbj.setFill(true);
		m_xbj.setNearAnchor(m_everyday_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, (m_tit.getShowHeight() - 20) + 10);

		DWTextbox m_tb = new DWTextbox("<mark c=55FF00>" + "购买每日任务数量：" + "</mark>");
		m_tb.setNearAnchor(m_xbj, Tools.LEFT_TOP, Tools.LEFT_TOP, 20, 20);

		m_left_ima = new DWImageBox(m_cr_left);
		m_left_ima.setNearAnchor(m_tb, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, 0, 15);
		m_left_ima.setTouchZoomIn(15, 20);
		m_left_ima.addListener(m_left_lis);

		m_input = new DWInputBox(m_xbj.getShowWidth() - 40 - m_tb.getShowWidth() - m_cr_right.getWidth() - 30,
				m_cr_right.getHeight() - 10, m_everyday_frame);
		m_input.setText(Integer.toString(m_longest));
		m_input.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_must_text != null)
				{
					int m_gold = Integer.parseInt(m_input.getText()) * m_yuanbao_huilv;
					m_must_text.setText("需要" + "<mark c=ffc001>" + m_gold + "</mark>");
					m_jinbi_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
				}
				if (m_count_text != null)
				{
					if (DWGameManager.getInstance().m_role.m_vip_lv == 0)
					{
						m_count_text.setText("<mark c=ffc001>" + "非VIP玩家，今日还可购买" + "</mark>" +
								"<mark c=55FF00>" + m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
					}
					else if (DWGameManager.getInstance().m_role.m_vip_lv > 0)
					{
						m_count_text.setText("<mark c=ffc001>" + "VIP"
								+ DWGameManager.getInstance().m_role.m_vip_lv + "玩家，今日还可购买" + "</mark>"
								+ "<mark c=55FF00>" + m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
					}
				}
			}
		});
		m_input.setNearAnchor(m_left_ima, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 15, 0);

		m_right_ima = new DWImageBox(m_cr_right);
		m_right_ima.setNearAnchor(m_input, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 15, 0);
		m_right_ima.setTouchZoomIn(15, 20);
		m_right_ima.addListener(m_right_lis);

		m_must_text = new DWTextbox("需要" + "<mark c=ffc001>" + m_gold + "</mark>");
		m_must_text.setNearAnchor(m_tb, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 10, m_left_ima.getShowHeight() + 30);

		m_jinbi_ima = new DWImageBox(m_cr_yunbao);
		m_jinbi_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);

		m_count_text = new DWTextbox("<mark c=ffc001>" + "今日还可购买" + "</mark>" + "<mark c=55FF00>" + m_longest
				+ "</mark>" + "<mark c=ffc001>" + "次" + "</mark>", m_xbj.getShowWidth() - 40);
		m_count_text.setNearAnchor(m_must_text, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, -10, 10);
		if (DWGameManager.getInstance().m_role.m_vip_lv == 0) {
			m_count_text.setText("<mark c=ffc001>" + "非VIP玩家，今日还可购买" + "</mark>" + "<mark c=55FF00>" + m_longest
					+ "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
		}
		else if (DWGameManager.getInstance().m_role.m_vip_lv > 0) {
			m_count_text.setText("<mark c=ffc001>" + "VIP" + DWGameManager.getInstance().m_role.m_vip_lv + "玩家，今日还可购买"
					+ "</mark>" + "<mark c=55FF00>" + m_longest + "</mark>" + "<mark c=ffc001>" + "次" + "</mark>");
		}

		m_but = new DWButton("确定", m_cr_but);
		m_but.setDownImage(m_cr_but_bianhou);
		m_but.setNearAnchor(m_count_text, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, -10, 15);
		m_but.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				int m_gold = Integer.parseInt(m_input.getText()) * m_yuanbao_huilv;
				m_count = Byte.parseByte(m_input.getText());
				if (m_gold > DWGameManager.getInstance().m_role.m_rmb)
				{
					DWGameManager.getInstance()
							.addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
									"抱歉，您的元宝不足" + m_gold + "，无法购买" + m_count + "次。");
				}
				else
				{
					if (m_longest == 0)
					{
						DWGameManager.getInstance()
								.addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉，您今日增次数量用尽。");
					}
					else if (m_longest > 0)
					{
						if (m_count > 0)
						{
							DWGameManager.getInstance().getSendMessage().sendAddEverydayBuy(m_count);
						}
						else
						{
							DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉,输入数量错误。");
						}
					}
				}
			}
		});

		m_everyday_frame.addControl(m_tit);
		m_everyday_frame.addControl(m_tit_ima);
		m_everyday_frame.addControl(m_tuichu_ima);
		m_everyday_frame.addControl(m_xbj);
		m_everyday_frame.addControl(m_tb);
		m_everyday_frame.addControl(m_left_ima);
		m_everyday_frame.addControl(m_right_ima);
		m_everyday_frame.addControl(m_input);
		m_everyday_frame.addControl(m_must_text);
		m_everyday_frame.addControl(m_jinbi_ima);
		m_everyday_frame.addControl(m_count_text);
		m_everyday_frame.addControl(m_but);
	}

	private DWListener m_left_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_input != null)
			{
				int m_left_input = Integer.parseInt(m_input.getText());
				if (m_left_input > 0)
				{
					int m_set_left_input = m_left_input - 1;
					m_input.setText(Integer.toString(m_set_left_input));
					m_must_text.setText("需要" + "<mark c=ffc001>" + m_set_left_input * m_yuanbao_huilv + "</mark>");
					m_jinbi_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
				}
				else
				{
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前数量为0，操作无效。");
				}
			}
		}
	};

	private DWListener m_right_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_input != null)
			{
				int m_right_input = Integer.parseInt(m_input.getText());
				if (m_right_input >= 0 && m_right_input < m_longest)
				{
					int m_set_right_input = m_right_input + 1;
					m_input.setText(Integer.toString(m_set_right_input));
					m_must_text.setText("需要" + "<mark c=ffc001>" + m_set_right_input * m_yuanbao_huilv + "</mark>");
					m_jinbi_ima.setNearAnchor(m_must_text, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5, 0);
				}
				else
				{
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前数量为今日购买上限，操作无效。");
				}
			}
		}
	};

	/**
	 * NPC任务
	 */
	////////////////npc身上的界面出现的接取任务监听
	private DWListener m_jiequ_but_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWControlsManager.getInstance().removeControl(m_jiequ_frame);
			DWGameManager.getInstance().getSendMessage().sendTaskBegin(m_task.m_key);
			UIWindows.getInstance().m_main.m_task = m_task;
			UIWindows.getInstance().m_main.m_animBox_renwu.setShow(false);
			UIWindows.getInstance().m_main.m_task_type = false;
			DWGameManager.getInstance().m_role.m_taskOpen = true;
		}
	};
	////npc身上的界面出现的放弃任务的监听
	private DWListener m_npc_fangqi_but_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWGameManager.getInstance().getSendMessage().sendTaskAbort(m_task.m_key);
		}
	};
	////////////npc身上的任务界面出现时的完成按钮监听
	private DWListener m_wc_but_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWGameManager.getInstance().getSendMessage().sendTaskFinish(m_task.m_key);
		}
	};

	public void init()
	{
		// 加载图片
		m_cr_tit_hq = UIWindows.createImage("/img/newui/huoqurenwu_1.gnp");
		m_cr_fangqi = UIWindows.createImage("/img/newui/fangqirenwu_1.gnp");
		m_cr_tit_wq = UIWindows.createImage("/img/newui/renwuwancheng_2.gnp");
		m_cr_tab_1 = UIWindows.createImage("/img/newui/biaoqianye_1.gnp");// 点击前图片
		m_cr_tab_2 = UIWindows.createImage("/img/newui/biaoqianye_2.gnp");// 点击后图片
		m_cr_tc = UIWindows.createImage("/img/newui/fanhuianniu_1.gnp"); // 退出叉键按钮的图片
		m_cr_but = UIWindows.createImage("/img/newui/anniu_6.gnp"); // /按钮的图片
		m_cr_but_bianhou = UIWindows.createImage("/img/newui/anniu_6ax.gnp");////按钮的改变后图片
		m_cr_xxbj = UIWindows.createImage("/img/newui/beibaobj_1.gnp");////小背景里面的2个小小背景
		m_cr_grid = UIWindows.createImage("/img/newui/wupinlan.gnp");
		m_cr_tit = UIWindows.createImage("/img/newui/renwu_1.gnp");
		m_cr_left = UIWindows.createImage("/img/newui/haoyoufyan_2.gnp");///个数翻页
		m_cr_right = UIWindows.createImage("/img/newui/haoyoufyan_1.gnp");
		m_cr_yunbao = UIWindows.createImage("/img/newui/yuanbao_1.gnp");
		m_cr_everyday_tit = UIWindows.createImage("/img/newui/meirizengci_1.gnp");
	}

	public void open(byte index)
	{
		// 开启窗口
		if (index == 0) {
			RenWu();
		}
		else if (index == 1) {
			NPC_Task_Information();
		}

	}

	public void close(byte index)
	{
		// 关闭窗口

	}

	public void dispose()
	{
		// 销毁图片

	}

	///////////////*******************接取任务界面***************************////////////////////

	/***************************** 网络接收 *****************************/
	/**
	 * 读取接受任务
	 * @param dis
	 * @throws IOException
	 */
	DWTextbox m_tb[];
	public boolean m_jiequ_flag = true;

	public void recvTaskBegin(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 1) {
			Tools.debugPrintln("接受任务 : " + state + " : " + msg);
			// 得到NPC列表中的任务
			// 创建一个新任务,并将NPC列表中的任务赋给新任务
			Task newTask = new Task();
			newTask.m_name = m_task.m_name;
			newTask.m_key = m_task.m_key;
			newTask.m_type = m_task.m_type;
			// 将新任务放入玩家任务列表
			DWGameManager.getInstance().m_role.m_drama_list.add(newTask);
			DWGameManager.getInstance().m_role.m_drama_list = UIRenWuWindow
					.taskSort(DWGameManager.getInstance().m_role.m_drama_list);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_C,
					"成功接取" + newTask.m_name + "任务！");
			////关闭接取任务的界面
			DWControlsManager.getInstance().removeControl(m_jiequ_frame);
//			DWGameManager.getInstance().getSendMessage().sendScenePathfinding(newTask.m_key);
			DWGameManager.getInstance().getSendMessage().sendTaskacceptablyTaskList();
		}
		else {
			Tools.debugPrintln("接受任务失败  : " + msg);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_A, msg);
		}
		UIWindows.getInstance().m_main.refreshTask();
	}

	/**
	 * 读取NPC任务详细信息
	 * @param dis
	 * @throws IOException
	 */
	String m_data_1 = new String();

	public void recvTaskViewNPC(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 1) {
			m_task = new Task();
			m_task.m_key = dis.readUTF();
			m_task.m_name = dis.readUTF();
			m_task.m_type = dis.readInt();
			m_task.m_lv = dis.readInt();
			m_task.m_difficulty = dis.readByte();
			m_task.m_status = dis.readByte();
			m_task.m_depict = dis.readUTF();
			m_task.m_progress = dis.readUTF();
			m_task.m_exp = dis.readInt();
			m_task.m_money = dis.readInt();
			Tools.debugPrintln("任务状态: " + m_task.m_status);
			Tools.debugPrintln("任务key: " + m_task.m_key);
			Tools.debugPrintln("任务名称: " + m_task.m_name);
			Tools.debugPrintln("任务类型: " + m_task.m_type);
			Tools.debugPrintln("任务等级: " + m_task.m_lv);
			Tools.debugPrintln("任务难度等级: " + m_task.m_difficulty);
			Tools.debugPrintln("任务描述: " + m_task.m_depict);
			Tools.debugPrintln("任务奖励经验数值: " + m_task.m_exp);
			Tools.debugPrintln("任务奖励金钱数值: " + m_task.m_money);

			if (DWControlsManager.getInstance().contains(m_rw_Frame)) {
				m_task_information_textbox[1].setText("<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">" + m_task.m_name
						+ "</mark>" + DWControlTools.CHANGE_ROW + m_task.m_depict
						+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "<mark c="
						+ getcolor(ItemConstants.稀有度_橙) + ">" + "任务奖励：" + "</mark>"
						+ DWControlTools.CHANGE_ROW + "奖励经验：" + m_task.m_exp + DWControlTools.CHANGE_ROW + "奖励金钱："
						+ m_task.m_money + "金");
				m_accept_but.setShow(true);
				m_accept_but.setTouch(true);
			}
			else {
				open((byte) 1);
				/////按钮
				if (m_task.m_status == 0) {
					m_tit_ima.setImage(m_cr_tit_hq);
					m_npc_but.setName("接取任务");
					m_npc_but.addListener(m_jiequ_but_lis);
				}
				else if (m_task.m_status == 1) {
					m_tit_ima.setImage(m_cr_fangqi);
					m_npc_but.setName("放弃任务");
					m_npc_but.addListener(m_npc_fangqi_but_lis);
				}
				else {
					m_tit_ima.setImage(m_cr_tit_wq);
					m_npc_but.setName("完成任务");
					m_npc_but.addListener(m_wc_but_lis);
				}

				//////文本框

				m_task.m_detail_size = 2;
				////关于道具
				byte propListCount = dis.readByte();
				m_task.m_detail_size += propListCount;
				Tools.debugPrintln("任务奖励道具列表长度 : " + propListCount);
				m_task.m_propID = new String[propListCount];
				m_task.m_propIcon = new short[propListCount];
				m_task.m_propName = new String[propListCount];
				m_task.m_propCount = new int[propListCount];
				for (byte i = 0; i < propListCount; i++) {
					m_task.m_propID[i] = dis.readUTF();
					m_task.m_propCount[i] = dis.readInt();
					m_task.m_propName[i] = dis.readUTF();
					m_task.m_propIcon[i] = dis.readShort();
					Tools.debugPrintln("任务奖励道具id" + i + " : " + m_task.m_propID[i]);
					Tools.debugPrintln("任务奖励道具数量" + i + " : " + m_task.m_propCount[i]);
				}

				/////关于声望
				byte renownListCount = dis.readByte();
				m_task.m_detail_size += renownListCount;
				Tools.debugPrintln("任务奖励声望列表长度 : " + renownListCount);
				m_task.m_renownID = new String[renownListCount];
				m_task.m_renownCount = new int[renownListCount];
				for (byte i = 0; i < renownListCount; i++) {
					m_task.m_renownID[i] = dis.readUTF();
					m_task.m_renownCount[i] = dis.readInt();
					Tools.debugPrintln("任务奖励声望目标id: " + i + " : " + m_task.m_renownID[i]);
					Tools.debugPrintln("任务奖励声望数值: " + i + " : " + m_task.m_renownCount[i]);
				}
				///显示NPC任务的详细信息的上面的textbox
				if (m_task.m_renownID == null || m_task.m_renownID.length == 0) {
					if (m_task.m_propCount == null || m_task.m_propCount.length == 0) {
						m_jiequ_textbox = new DWTextbox("<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">"
								+ m_task.m_name + "</mark>" + DWControlTools.CHANGE_ROW + m_task.m_depict
								+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "<mark c="
								+ getcolor(ItemConstants.稀有度_橙) + ">" + "任务奖励：" + "</mark>"
								+ DWControlTools.CHANGE_ROW + "奖励经验：" + m_task.m_exp + DWControlTools.CHANGE_ROW
								+ "奖励金钱：" + m_task.m_money + "金", m_daoju_listbox.getShowWidth());
						DWListSubItem m_lsi = new DWListSubItem();
						m_jiequ_textbox.setNearAnchor(m_lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
						m_lsi.addControls(m_jiequ_textbox);
						m_daoju_listbox.addSubItem(m_lsi);
					}
					else {
						m_jiequ_textbox = new DWTextbox("<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">"
								+ m_task.m_name + "</mark>" + DWControlTools.CHANGE_ROW + m_task.m_depict
								+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "<mark c="
								+ getcolor(ItemConstants.稀有度_橙) + ">" + "任务奖励：" + "</mark>"
								+ DWControlTools.CHANGE_ROW + "奖励经验 ：" + m_task.m_exp + DWControlTools.CHANGE_ROW
								+ "奖励金钱：" + m_task.m_money + "金" + DWControlTools.CHANGE_ROW
								+ "<mark c=" + getcolor(ItemConstants.稀有度_橙) + ">" + "奖励道具：" + "</mark>",
								m_daoju_listbox.getShowWidth());

						m_daoju = new DWImageBox[m_task.m_propCount.length];
						m_daoju_di = new DWImageBox[m_task.m_propCount.length];
						IconManger m_iconmanger = new IconManger();
						m_lsi = new DWListSubItem[m_task.m_propCount.length + 1];
						for (int i = 0; i < m_task.m_propCount.length + 1; i++) {
							m_lsi[i] = new DWListSubItem();
							if (i == 0) {
								m_jiequ_textbox.setNearAnchor(m_lsi[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
								m_lsi[i].addControls(m_jiequ_textbox);
							}
							else {
								m_daoju_di[i - 1] = new DWImageBox(m_cr_grid);
								m_daoju[i - 1] = new DWImageBox(m_iconmanger.getIcon(m_task.m_propIcon[i - 1]));
								m_daoju_di[i - 1].setNearAnchor(m_lsi[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
								m_daoju[i - 1].setNearAnchor(m_lsi[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);

								DWTextbox m_daoju_textbox = new DWTextbox(m_task.m_propName[i - 1] + " × "
										+ m_task.m_propCount[i - 1]);
								m_daoju_textbox.setNearAnchor(m_daoju[i - 1], Tools.LEFT_BOTTOM, Tools.RIGHT_BOTTOM, 5,
										0);
								final int j = i - 1;
								m_daoju[i - 1].addListener(new DWListener() {
									public void OnDoubleClick()
									{
									}

									public void OnClick()
									{
										m_daoju[j].setSelect(true);
										DWGameManager.getInstance().getSendMessage().sendSeeItemInfos(0,
												m_task.m_propID[m_daoju_listbox.getTouchIndex() - 1]);
									}
								});
								m_lsi[i].addControls(m_daoju_di[i - 1]);
								m_lsi[i].addControls(m_daoju[i - 1]);
								m_lsi[i].addControls(m_daoju_textbox);
							}
							m_daoju_listbox.addSubItem(m_lsi[i]);
						}
					}
				}
				else {
					if (m_task.m_propCount == null || m_task.m_propCount.length == 0) {
						m_jiequ_textbox = new DWTextbox("<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">"
								+ m_task.m_name + "</mark>" + DWControlTools.CHANGE_ROW + m_task.m_depict
								+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "<mark c="
								+ getcolor(ItemConstants.稀有度_橙) + ">" + "任务奖励：" + "</mark>"
								+ DWControlTools.CHANGE_ROW + "奖励经验：" + m_task.m_exp + DWControlTools.CHANGE_ROW
								+ "奖励金钱：" + m_task.m_money + "金" + DWControlTools.CHANGE_ROW + m_task.m_renownID[0]
								+ "：" + m_task.m_renownCount[0], m_daoju_listbox.getShowWidth());
						DWListSubItem m_lsi_1 = new DWListSubItem();
						m_jiequ_textbox.setNearAnchor(m_lsi_1, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
						m_lsi_1.addControls(m_jiequ_textbox);
						m_daoju_listbox.addSubItem(m_lsi_1);
					}
					else {
						m_jiequ_textbox = new DWTextbox("<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">"
								+ m_task.m_name + "</mark>" + DWControlTools.CHANGE_ROW + m_task.m_depict
								+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "<mark c="
								+ getcolor(ItemConstants.稀有度_橙) + ">" + "任务奖励：" + "</mark>"
								+ DWControlTools.CHANGE_ROW + "奖励经验：" + m_task.m_exp + DWControlTools.CHANGE_ROW
								+ "奖励金钱：" + m_task.m_money + "金" + DWControlTools.CHANGE_ROW
								+ m_task.m_renownID[0] + "：" + m_task.m_renownCount[0] + DWControlTools.CHANGE_ROW
								+ "<mark c=" + getcolor(ItemConstants.稀有度_橙) + ">" + "奖励道具：" + "</mark>",
								m_daoju_listbox.getShowWidth());
						m_daoju = new DWImageBox[m_task.m_propCount.length];
						m_daoju_di = new DWImageBox[m_task.m_propCount.length];
						IconManger m_iconmanger = new IconManger();
						m_lsi_2 = new DWListSubItem[m_task.m_propCount.length + 1];
						for (int i = 0; i < m_task.m_propCount.length + 1; i++) {
							m_lsi_2[i] = new DWListSubItem();
							if (i == 0) {
								m_jiequ_textbox.setNearAnchor(m_lsi_2[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
								m_lsi_2[i].addControls(m_jiequ_textbox);
							}
							else {
								m_daoju_di[i - 1] = new DWImageBox(m_cr_grid);
								m_daoju[i - 1] = new DWImageBox(m_iconmanger.getIcon(m_task.m_propIcon[i - 1]));
								m_daoju_di[i - 1].setNearAnchor(m_lsi_2[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
								m_daoju[i - 1].setNearAnchor(m_lsi_2[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);

								DWTextbox m_daoju_textbox = new DWTextbox(m_task.m_propName[i - 1] + " × "
										+ m_task.m_propCount[i - 1]);
								m_daoju_textbox.setNearAnchor(m_daoju[i - 1], Tools.LEFT_BOTTOM, Tools.RIGHT_BOTTOM, 5,
										0);

								final int j = i - 1;
								m_daoju[i - 1].addListener(new DWListener() {
									public void OnDoubleClick()
									{
									}

									public void OnClick()
									{
										m_daoju[j].setSelect(true);
										DWGameManager.getInstance().getSendMessage().sendSeeItemInfos(0,
												m_task.m_propID[j]);
									}
								});
								m_lsi_2[i].addControls(m_daoju_di[i - 1]);
								m_lsi_2[i].addControls(m_daoju[i - 1]);
								m_lsi_2[i].addControls(m_daoju_textbox);
							}
							m_daoju_listbox.addSubItem(m_lsi_2[i]);
						}
					}
				}
			}
			DWControlsManager.getInstance().removeControl(
					((SceneHandler) DWGameManager.getInstance().getGameHandler()).m_scene.m_dwDMNPCTaskList);
		}
		else {
			Tools.debugPrintln("读取NPC任务详细信息失败 : " + msg);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_A, msg);
		}
		UIWindows.getInstance().m_main.refreshTask();
	}

	/**
	 * 读取完成任务
	 * 
	 * @param dis
	 * @throws IOException
	 */
	public void recvTaskFinish(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		short state = dis.readShort();
		String msg = dis.readUTF();
		if (state == 1) {
			Tools.debugPrintln("完成任务 : " + state + " : msg : " + msg);
			int money = dis.readInt();
			int exp = dis.readInt();
			Tools.debugPrintln("获得金钱 : " + money);
			Tools.debugPrintln("获得经验 : " + exp);
			Tools.debugPrintln("任务ID : " + m_task.m_key);
			CopyOnWriteArrayList<Task> al = null;
			///在这里将之前java的gamemanage换成现在的UIWindows,m_role换成了m_renwu
			al = DWGameManager.getInstance().m_role.m_drama_list;
			for (int i = 0; i < al.size(); i++) {
				Task temp = (Task) al.get(i);
				if (temp.m_key.equals(m_task.m_key)) {
					DWGameManager.getInstance().m_role.m_drama_list.remove(i);
					if (DWControlsManager.getInstance().contains(m_rw_Frame)
							&& m_rw_Frame.contains(m_listbox_data[0]) && m_listbox_data[0] != null) {
						m_listbox_data[0].removeSubItem(i);
						m_listbox_data[0].refreshControl();
					}
					break;
				}
			}
//			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, m_task.m_name+"任务完成。");
			DWControlsManager.getInstance().removeControl(m_jiequ_frame);
			Scene scene = ((SceneHandler) DWGameManager.getInstance().getGameHandler()).m_scene;
			scene.addUpgradeAnimAction(scene.m_upgradeAction_wcrw);
			DWGameManager.getInstance().getSendMessage().sendTaskacceptablyTaskList();
			UIWindows.getInstance().m_main.refreshTask();
		}
		else {
			Tools.debugPrintln("完成任务失败  : " + msg);
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, msg);
		}
		UIWindows.getInstance().m_main.refreshTask();
	}

	/********************************* 查看NPC任务详情界面 *****************************/
	DWFrame m_jiequ_frame = null;
	DWTitle m_jiequ_tit;
	DWTextbox m_jiequ_textbox;
	DWImageBox m_daoju[];
	DWImageBox m_daoju_di[];
	DWListbox m_daoju_listbox;
	Bitmap m_cr_tit_hq = null;
	Bitmap m_cr_tit_wq = null;
	DWImageBox m_tit_ima;

	public void NPC_Task_Information()
	{
		if (DWControlsManager.getInstance().contains(m_jiequ_frame)) {
			if (m_jiequ_frame != null) {
				DWControlsManager.getInstance().removeControl(m_jiequ_frame);
			}
		}

		/////画布
		m_jiequ_frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_HCENTER, true);
		m_jiequ_frame.setClickClose(false);
		m_jiequ_frame.setThrough(true);
		/////标题
		m_jiequ_tit = new DWTitle("", m_jiequ_frame);
		m_tit_ima = new DWImageBox(m_cr_tit_hq);
		m_tit_ima.setNearAnchor(m_jiequ_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		////小背景
		m_xbj_bg = new DWBackground(m_jiequ_frame.getShowWidth() - 30,
				m_jiequ_frame.getShowHeight() - (m_jiequ_tit.getShowHeight() - 20) - 30);
		m_xbj_bg.setNearAnchor(m_jiequ_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 15,
				(m_jiequ_tit.getShowHeight() - 20) + 15);

		/////叉键退出
		m_tc_ima = new DWImageBox(m_cr_tc);
		m_tc_ima.addListener(m_jiequ_tc_lis);
		m_tc_ima.setTouchZoomIn(40, 40);
		m_tc_ima.setNearAnchor(m_jiequ_tit, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);

		m_daoju_listbox = new DWListbox(m_xbj_bg.getShowWidth() - 18, m_xbj_bg.getShowHeight()
				- m_cr_but.getHeight() - 10);
		m_daoju_listbox.setNearAnchor(m_xbj_bg, Tools.LEFT_TOP, Tools.LEFT_TOP, 9, 10);
		m_daoju_listbox.setShowBackgroundRect(false);

		m_npc_but = new DWButton("", m_cr_but);
		m_npc_but.setDownImage(m_cr_but_bianhou);
		m_npc_but.addListener(m_jiequ_but_lis);
		m_npc_but.setNearAnchor(m_xbj_bg, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -0, -0);

		m_jiequ_frame.addControl(m_jiequ_tit);
		m_jiequ_frame.addControl(m_tit_ima);
		m_jiequ_frame.addControl(m_xbj_bg);
		m_jiequ_frame.addControl(m_tc_ima);
		m_jiequ_frame.addControl(m_npc_but);
		m_jiequ_frame.addControl(m_daoju_listbox);
		DWControlsManager.getInstance().addControl(m_jiequ_frame);
	}

	private DWListener m_jiequ_tc_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWControlsManager.getInstance().removeControl(m_jiequ_frame);
		}
	};

	/**
	 * 更新玩家身上任务状态
	 * @param dis
	 * @throws IOException
	 */
	public void recvTaskUpdateStatus(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_任务);
		String key = dis.readUTF();
		byte status = dis.readByte();
		String progress = dis.readUTF();
		Tools.debugPrintln("更新任务状态 : " + key + " : " + status);
		CopyOnWriteArrayList<Task> list = DWGameManager.getInstance().m_role.m_drama_list;
		if (list != null) {
			Task task;
			int len = list.size();
			for (int i = 0; i < len; i++) {
				task = list.get(i);
				if (task != null && task.m_key.equals(key)) {
					task.m_status = status;
					task.m_progress = progress;
					if (status == 2) {
						if (DWGameManager.getInstance().m_role.m_taskOpen
								&& UIWindows.getInstance().m_main.m_task != null
								&& key.equals(UIWindows.getInstance().m_main.m_task.m_key)) {
							UIHook.closeHook();
							DWGameManager.getInstance().m_role.m_taskOpen = false;
							UIWindows.getInstance().m_main.m_animBox_renwu.setShow(true);
							UIWindows.getInstance().m_main.m_task_time = 0;
							UIWindows.getInstance().m_main.m_task_type = true;
							UIWindows.getInstance().m_main.task_anim();
						}
						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
								task.m_name + "任务完成。");
					}
					break;
				}
			}
			UIWindows.getInstance().m_main.refreshTask();
		}
	}

	public void logic()
	{

	}

	private DWListener m_textbox_lis = new DWListener() {

		public void OnDoubleClick()
		{

		}

		public void OnClick()
		{
			int m_index_1 = m_listbox_data[m_tabcontrol.getPageIndex()].getTouchIndex();
			Task m_task_list = null;
			if (m_tabcontrol.getPageIndex() == 0) {
				m_task_list = DWGameManager.getInstance().m_role.m_drama_list.get(m_index_1);
			}
			else if (m_tabcontrol.getPageIndex() == 1) {
				m_task_list = DWGameManager.getInstance().m_role.m_acceptably_list.get(m_index_1);
			}
			if (m_task_list != null) {
				m_task_operate_id = m_index_1;
				if (m_tabcontrol.getPageIndex() == 0) {
					DWGameManager.getInstance().getSendMessage().sendRoleTaskView(m_task_list.m_key);
				}
				else if (m_tabcontrol.getPageIndex() == 1) {
					DWGameManager.getInstance().getSendMessage().sendNPCTaskView(m_task_list.m_key);
				}
			}
		}
	};

	public static String getcolor(int index)
	{
		String color = "";
		switch (index) {
			case ItemConstants.稀有度_灰:
				color = "999999";
				break;
			case ItemConstants.稀有度_白:
				color = "ffffff";
				break;
			case ItemConstants.稀有度_蓝:
				color = "00BBFF";
				break;
			case ItemConstants.稀有度_绿:
				color = "55FF00";
				break;
			case ItemConstants.稀有度_紫:
				color = "9900FF";
				break;
			case ItemConstants.稀有度_橙:
				color = "FFBB11";
				break;
			case ItemConstants.稀有度_红:
				color = "FF3300";
				break;
		}
		return color;
	}

	/**
	 * 对任务列表排序,根据类型,从小到大
	 * @param tasklist
	 * @return
	 */
	public static CopyOnWriteArrayList<Task> taskSort(CopyOnWriteArrayList<Task> tasklist)
	{
		if (tasklist == null) {
			return null;
		}
		CopyOnWriteArrayList<Task> tempTaskList = new CopyOnWriteArrayList<Task>();
		for (int i = 0; i < tasklist.size(); i++) {
			Task task = tasklist.get(i);
			boolean finish = false;
			for (int j = 0; j < tempTaskList.size(); j++) {
				Task tempTask = tempTaskList.get(j);
				if (tempTask.m_type > task.m_type) {
					tempTaskList.add(j, task);
					finish = true;
					break;
				}
			}
			if (!finish) {
				tempTaskList.add(task);
			}
		}
		return tempTaskList;
	}

	public DWControl getNPCButton()
	{
		if (DWControlsManager.getInstance().contains(m_jiequ_frame) && m_npc_but != null) {
			return m_npc_but;
		}
		return null;
	}

}
